package com.realtime.sys.config;

import com.realtime.sys.websocket.UiWebSocket;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;

@Configuration
public class WebSocketConfig {

    @Autowired
    private ApplicationContext applicationContext;

    @Bean
    public ServerEndpointExporter serverEndpointExporter() {
        // 将 ApplicationContext 注入到 UiWebSocket
        UiWebSocket.setApplicationContext(applicationContext);
        return new ServerEndpointExporter();
    }
}
